#!/bin/bash

# 创建备份目录
BACKUP_DIR="halo_backup_$(date +%Y%m%d_%H%M%S)"
mkdir -p $BACKUP_DIR

# 备份 docker-compose.yaml
cp docker-compose.yaml $BACKUP_DIR/

# 备份 Halo 数据
cp -r .halo2 $BACKUP_DIR/

# 备份 PostgreSQL 数据
docker-compose exec postgresql pg_dump -U halo halo > $BACKUP_DIR/halo_db_backup.sql

# 压缩备份文件
tar -czf ${BACKUP_DIR}.tar.gz $BACKUP_DIR
rm -rf $BACKUP_DIR

echo "备份完成，文件保存在: ${BACKUP_DIR}.tar.gz" 